package com.lysj.admin.master.bussiness.company.invoice.service;

import com.lysj.admin.master.bussiness.company.invoice.domain.InvoiceInfo;
import com.lysj.admin.master.bussiness.company.invoice.mapper.InvoiceInfoMapper;
import com.lysj.admin.master.common.spring.mpbase.MyService;
import com.lysj.admin.master.common.web.ParamUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;

/**
 * @author Created by drj on 2020-01-08 14:55
 * @description
 */
@Slf4j
@Service
@Transactional
public class InvoiceInfoService extends MyService<InvoiceInfoMapper, InvoiceInfo> {


    public InvoiceInfo findByCompanyId(String companyId) {
        InvoiceInfo invoiceInfo = this.lambdaQuery()
                .eq(InvoiceInfo::getCompanyId, companyId)
                .one();
        if (ParamUtil.isBlank(invoiceInfo)) {
            invoiceInfo = new InvoiceInfo();
            invoiceInfo.setCompanyId(companyId);
            this.save(invoiceInfo);
        }
        return invoiceInfo;
    }
}
